/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.cggveritas.crewintranet.jms.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author Alassane
 */
@Entity
@Table(name = "cv_travail")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CvTravail.findAll", query = "SELECT c FROM CvTravail c"),
    @NamedQuery(name = "CvTravail.findByCvTravailleurId", query = "SELECT c FROM CvTravail c WHERE c.cvTravailleurId = :cvTravailleurId"),
    @NamedQuery(name = "CvTravail.findByDebutcontrat", query = "SELECT c FROM CvTravail c WHERE c.debutcontrat = :debutcontrat"),
    @NamedQuery(name = "CvTravail.findByFincontrat", query = "SELECT c FROM CvTravail c WHERE c.fincontrat = :fincontrat")})
public class CvTravail implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "cv_travailleur_id")
    private Integer cvTravailleurId;
    @Column(name = "debutcontrat")
    @Temporal(TemporalType.DATE)
    private Date debutcontrat;
    @Column(name = "fincontrat")
    @Temporal(TemporalType.DATE)
    private Date fincontrat;
    @OneToMany(mappedBy = "travailleurId", fetch = FetchType.LAZY)
    private List<CvHistoriquechangementsalaire> cvHistoriquechangementsalaireList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvTravail", fetch = FetchType.LAZY)
    private List<CvTravailprime> cvTravailprimeList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cvTravailCvTravailleurId", fetch = FetchType.LAZY)
    private List<CvPointageheuresup> cvPointageheuresupList;
    @JoinColumn(name = "idcompagnie", referencedColumnName = "idcompagnie")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvCompagnie idcompagnie;
    @JoinColumn(name = "typecontrat", referencedColumnName = "typecontrat")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private CvTypedecontrat typecontrat;
    @JoinColumn(name = "cv_travailleur_id", referencedColumnName = "id", insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private CvTravailleur cvTravailleur;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "cvTravail", fetch = FetchType.LAZY)
    private CvSalaire cvSalaire;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "travailleurId", fetch = FetchType.LAZY)
    private List<CvPointage> cvPointageList;

    public CvTravail() {
    }

    public CvTravail(Integer cvTravailleurId) {
        this.cvTravailleurId = cvTravailleurId;
    }

    public Integer getCvTravailleurId() {
        return cvTravailleurId;
    }

    public void setCvTravailleurId(Integer cvTravailleurId) {
        this.cvTravailleurId = cvTravailleurId;
    }

    public Date getDebutcontrat() {
        return debutcontrat;
    }

    public void setDebutcontrat(Date debutcontrat) {
        this.debutcontrat = debutcontrat;
    }

    public Date getFincontrat() {
        return fincontrat;
    }

    public void setFincontrat(Date fincontrat) {
        this.fincontrat = fincontrat;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvHistoriquechangementsalaire> getCvHistoriquechangementsalaireList() {
        return cvHistoriquechangementsalaireList;
    }

    public void setCvHistoriquechangementsalaireList(List<CvHistoriquechangementsalaire> cvHistoriquechangementsalaireList) {
        this.cvHistoriquechangementsalaireList = cvHistoriquechangementsalaireList;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvTravailprime> getCvTravailprimeList() {
        return cvTravailprimeList;
    }

    public void setCvTravailprimeList(List<CvTravailprime> cvTravailprimeList) {
        this.cvTravailprimeList = cvTravailprimeList;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvPointageheuresup> getCvPointageheuresupList() {
        return cvPointageheuresupList;
    }

    public void setCvPointageheuresupList(List<CvPointageheuresup> cvPointageheuresupList) {
        this.cvPointageheuresupList = cvPointageheuresupList;
    }

    public CvCompagnie getIdcompagnie() {
        return idcompagnie;
    }

    public void setIdcompagnie(CvCompagnie idcompagnie) {
        this.idcompagnie = idcompagnie;
    }

    public CvTypedecontrat getTypecontrat() {
        return typecontrat;
    }

    public void setTypecontrat(CvTypedecontrat typecontrat) {
        this.typecontrat = typecontrat;
    }

    public CvTravailleur getCvTravailleur() {
        return cvTravailleur;
    }

    public void setCvTravailleur(CvTravailleur cvTravailleur) {
        this.cvTravailleur = cvTravailleur;
    }

    public CvSalaire getCvSalaire() {
        return cvSalaire;
    }

    public void setCvSalaire(CvSalaire cvSalaire) {
        this.cvSalaire = cvSalaire;
    }

    @XmlTransient
    @JsonIgnore
    public List<CvPointage> getCvPointageList() {
        return cvPointageList;
    }

    public void setCvPointageList(List<CvPointage> cvPointageList) {
        this.cvPointageList = cvPointageList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cvTravailleurId != null ? cvTravailleurId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CvTravail)) {
            return false;
        }
        CvTravail other = (CvTravail) object;
        if ((this.cvTravailleurId == null && other.cvTravailleurId != null) || (this.cvTravailleurId != null && !this.cvTravailleurId.equals(other.cvTravailleurId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "fr.cggveritas.crewintranet.jms.entities.CvTravail[ cvTravailleurId=" + cvTravailleurId + " ]";
    }
    
}
